import React from 'react'
const {Provider, Consumer} = React.createContext('username')

class Father extends React.Component {
  render () {
    return (
      <Provider value='newming'>
      <div>
        <h1>我是</h1>
        <Son />
      </div>
      </Provider>
    )
  }
}

export default Father

class Son extends React.Component {
  render () {
    return (
      <div>
        <h1>Son</h1>
        <SonSong />
      </div>
    )
  }
}
class SonSong extends React.Component {
  render () {
    return (
      <Consumer>
        {name => <h1>{name}</h1>}
      </Consumer>
    )
  }
}